while True:
    pm25=input("请输入pm2.5数值(pm2.5数值为非负正整数，格式为阿拉伯数字)(输入大写Q退出空气质量查询工具):")
    if pm25=="Q":
        print("退出空气质量查询工具")
        break
    else:
        if pm25.isdecimal():
            pm25 = int(pm25)
            if 0 <= pm25 <= 50: print("优")
            if 51 <= pm25 <= 100: print("良")
            if 101 <= pm25 <= 150: print("轻度污染")
            if 151 <= pm25 <= 200: print("中度污染")
            if 201 <= pm25 <= 300: print("重度污染")
            if pm25 > 300: print("严重污染")
        else:
            print("输入有误，请重新输入")
            continue